package cn.janyd.jmall.management.controller.passport;

import cn.janyd.common.core.vo.CommonResult;
import cn.janyd.jmall.management.controller.passport.vo.AdminLoginDTO;
import cn.janyd.jmall.management.controller.passport.vo.PassportTokenRespVo;
import cn.janyd.jmall.management.manager.passport.PassportManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static cn.janyd.common.core.vo.CommonResult.success;

/**
 * @author Janyd
 * @since 2020-08-15 17:25
 */
@Api(tags = "管理后台Passport")
@RestController
@RequestMapping("/passport")
@AllArgsConstructor
public class PassportController {

    private final PassportManager passportManager;

    @PostMapping("/login")
    @ApiOperation("登录后台")
    public CommonResult<PassportTokenRespVo> login(@RequestBody @Valid AdminLoginDTO adminLogin) {
        PassportTokenRespVo passportTokenRespVo = passportManager.login(adminLogin);
        return success(passportTokenRespVo);
    }
}
